/*
 * @Author: ylq
 * @Date: 2022-09-13 11:48:49
 * @Desc: config 基础配置
 * @Last Modified by: ylq
 * @Last Modified time: 2023-12-12 16:10:00
 */
import { resolve } from 'path';
// import { fileURLToPath, URL } from 'node:url';
// const pxtoviewport = require('postcss-px-to-viewport');
import pxtoviewport from 'postcss-px-to-viewport';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import legacy from '@vitejs/plugin-legacy';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver, VantResolver } from 'unplugin-vue-components/resolvers';
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    legacy({
      targets: ['defaults', 'not IE 11']
    }),
    Components({
      resolvers: [VantResolver(), ElementPlusResolver()]
    })
  ],
  resolve: {
    alias: {
      // '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@': resolve('./src'),
      vue: 'vue/dist/vue.esm-bundler.js' // compile template
    },
    extensions: ['.jsx', '.js', '.mjs']
  },
  css: {
    loaderOptions: {
      postcss: {
        plugins: [
          pxtoviewport({
            viewportWidth: 375
          })
        ]
      }
    }
  },
  define: {
    // 'process.env': {}
  }
  // optimizeDeps: {
  //   include: ['@kangc/v-md-editor/lib/theme/vuepress.js'],
  // },
});
